package org.example.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfigruationSetting {

    // 替换 Docket - 创建全局 OpenAPI 配置
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("盈利宝项目")
                        .version("1.0")
                        .description("盈利宝前后端分离微服务项目")
                        .contact(new Contact()
                                .name("动力节点java")
                                .url("http://www.bjpowernode.com")
                                .email("bjpowernode@bjpowenrode.cn"))
                        .license(new License()
                                .name("Apache 2.0")
                                .url("https://www.apache.org/licenses/LICENSE-2.0")));
    }

    // 创建分组API
    @Bean
    public GroupedOpenApi controllerApi() {
        return GroupedOpenApi.builder()
                .group("controller-api") // 分组名称
                .packagesToScan("org.example.controller") // 指定扫描的包
                .pathsToMatch("/**") // 匹配所有路径
                .build();
    }

}